// 输入年和月，输出该月有几天。

#include <stdio.h>
char get_day(int year, int month)
{
    static char month_day[] = {
        31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    bool isRun;
    if (year % 100 == 0)
    {
        isRun = year % 400 == 0;
    }
    else
    {
        isRun = year % 4 == 0;
    }
    auto daycnt = month_day[month - 1];
    if (isRun && month == 2)
    {
        daycnt++;
    }
    return daycnt;
}
int main()
{

    int a, b;
    scanf("%d %d", &a, &b);

    printf("%d", get_day(a, b));

    return 0;
}